﻿using System;
using System.Collections.Generic;

namespace CardPlay.Model.Primitives
{
    public static class ExtensionsToIList
    {
        public static IList<T> Shuffle<T>(this IList<T> list, Func<int, int> next)
        {
            for (var target = list.Count - 1; target > 0; --target)
            {
                var source = next(target);

                var item = list[target];
                list[target] = list[source];
                list[source] = item;
            }

            return list;
        }
    }
}
